/**
 * @description sequelize实例
 * @author 印明帝
 */

const Sequelize = require('sequelize')
const { isProd,isTest } = require('../utils/env')
const { MYSQL_CONF } = require('../conf/db')
// 获取配置对象内的值
const { host,port,database,user,password,dialect,pool } = MYSQL_CONF
let conf = {
  host,
  port,
  dialect,
  logging: true
}
// 线上模式采用连接池
if(isProd) {
  conf.pool = pool
}
// 如果是测试模式关闭sequelize打印sql语句
// if( isTest ) {
// }

// 创建sequelize实例
// 数据库名称，用户名，密码，配置
const seq = new Sequelize(database,user,password,conf)

module.exports = seq
